<!DOCTYPE html>
<html>
<head>
  <title>用户列表</title>
</head>
<body>
<a href="index.php?c=user&m=userform">添加用户</a>
<h1><center>用户列表</center></h1>
 <table align="center" border="1"> 
 <tr>
   <th>用户编号</th>
   <th>用户名</th>   
   <th>性别</th>
   <th>生日</th>
   <th>爱好</th>
   <th>学历</th>
   <th>自我介绍</th> 
   <th width='100'>头像</th>
   <th>操作</th>
 </tr>

<?php
  define('UserPhotoPath','images/');
  static $count=0;
  //var_dump($data);
  if(array_key_exists('uid',$data['users'])){
    $row = $data['users'];
    $count=1;
    echo '<tr>';
    echo '<td>'.$row['uid'].'</td>';
    echo '<td>'.$row['uname'].'</td>';  
    echo '<td>'.($row['gender']==0?'男':'女').'</td>';
    echo '<td>'.$row['birthdate'].'</td>';
    echo '<td>'.$row['hobby'].'</td>';
    switch($row['degree']){
      case '1':$dg = "高中";break;
      case '2':$dg = "大学";break;
      case '3':$dg = "研究生";break;
      case '4':$dg = "博士生";break;
      default: $dg="不知道";
    }
    echo '<td>'.$dg.'</td>';
    echo '<td>'.$row['intro'].'</td>';    
    echo '<td align="center"><img src='.UserPhotoPath.$row['pic'].' width=85 height=80 alt="无头像"></td>';  
    echo '<td><a href="index.php?c=user&m=useredit&id='.$row['uid'].' ">修改</a> | 
    <a href="index.php?c=user&m=deluser&id='.$row['uid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a></td>';
    echo '</tr>';
  }else{
    foreach($data['users'] as $row){
      $count++;
      echo '<tr>';
      echo '<td>'.$row['uid'].'</td>';
      echo '<td>'.$row['uname'].'</td>';  
      echo '<td>'.($row['gender']==0?'男':'女').'</td>';
      echo '<td>'.$row['birthdate'].'</td>';
      echo '<td>'.$row['hobby'].'</td>';
      switch($row['degree']){
        case '1':$dg = "高中";break;
        case '2':$dg = "本科";break;
        case '3':$dg = "研究生";break;
        case '4':$dg = "博士生";break;
        default: $dg="不知道";
      }
      echo '<td>'.$dg.'</td>';
      echo '<td>'.$row['intro'].'</td>';    
      echo '<td align="center"><img src='.UserPhotoPath.$row['pic'].' width=95 height=100 alt="无头像"></td>';  
      echo '<td><a href="index.php?c=user&m=useredit&id='.$row['uid'].' ">修改</a> | 
      <a href="index.php?c=user&m=deluser&id='.$row['uid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a></td>';
      echo '</tr>';  
    }
  }
  echo '</table>';  
  echo "<table align='center'><tr><td>共有 {$count} 名用户</td></tr></table>";   
 ?>
 </body>
</html>